<!--
 * @Author: Ping Chou
 * @Date: 2021-11-29 14:15:17
 * @LastEditTime: 2021-11-29 15:42:05
 * @LastEditors: zhouping
 * @Description: 盒模型
 * @FilePath: /test1/flex.html
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      .box {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
      }
      .item {
        /* width: 33%; */
        /* flex-grow: 1;
      flex-basis: 100px;
      flex-shrink: 0; */
        background-color: aqua;
        flex: 0 0 25%;
      }
    </style>
  </head>
  <body>
    <div class="box">
      <div class="item">1</div>
      <div class="item">2</div>
      <div class="item">3</div>
      <div class="item">4</div>
    </div>
    <script>
      // const clientWidth = window.clientWidth
      // const itemLength = document.querySelectorAll('.item').length
      // const itemwidth = clientWidth / 3
      // function toPercent(num, total) {
      //   return Math.round((total / num) * 100) / 100 + '%' // 小数点后两位百分比
      // }
      // console.log(111)
      // console.log(toPercent(7, 100))
    </script>
  </body>
</html>
